package com.example.home.activity

import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.base.BaseActivity
import com.example.config.KeyConfig
import com.example.home.R
import com.example.home.adapter.FingerShapeRvAdapter
import com.example.home.data.FingerRvItem

class FingerShapeAct : BaseActivity() {

    private lateinit var fingerShapeRvAdapter: FingerShapeRvAdapter

    private val items = listOf(
        FingerRvItem(0,R.mipmap.app_icon, "Mi型音阶"),
        FingerRvItem(1,R.mipmap.app_icon, "Sol型音阶"),
        FingerRvItem(2,R.mipmap.app_icon, "La型音阶"),
        FingerRvItem(3,R.mipmap.app_icon, "Si型音阶"),
        FingerRvItem(4,R.mipmap.app_icon, "Re型音阶")
    )

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        // 使用 DataBindingUtil 设置布局
        val binding = DataBindingUtil.setContentView<com.example.home.databinding.FragFingerShapeBinding>(this, R.layout.frag_finger_shape)

        binding.homeFragTitle.baseTitleTvMiddle.text = getString(R.string.guitar_fingering_training)
        binding.homeFragTitle.baseTitleIvLeft.visibility = View.VISIBLE

        binding.fingerShapeRv.layoutManager = LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false)
        fingerShapeRvAdapter = FingerShapeRvAdapter(items)

        fingerShapeRvAdapter.onClickListener = { item->
            intent = Intent(this,FingerShapeDetailAct::class.java)
            intent.putExtra(KeyConfig.FINGER_SHAPE_IS,item.id)
            startActivity(intent)
        }
        binding.fingerShapeRv.adapter = fingerShapeRvAdapter

        binding.homeFragTitle.viewBack.setOnClickListener {
            finish()
        }

    }

}
